<?php
/**
 * 描述：企业商铺-公共调用类。
 * @abstract
 */
abstract class Exec_Store_Public extends Exec
{
    public function Get()
    {
        #获取参数
        $id=Functions::UrlArgs('id');
        if(!is_numeric($id))
        {
            echo 'error';
            exit();
        }

        #获取会员数据
        $account=DB::GetRowByID('account',$id);
        if(!$account)
        {
            echo 'nothing';
            header("HTTP/1.0 404 Not Found");
            exit();
        }
        $account['Description']=NULL;
        {
            $intro=explode('。',$account['Intro']);
            $account['Description']=@$intro[0].'。'.@$intro[1].'。';
        }
        $account['SubTrade']=NULL;
        {
            foreach(explode(',',$account['Trade_Subclass']) as $classID)
            {
                if(is_numeric($classID))
                {
                    $tmp=@DB::GetRowByID('trade','Identifying:'.$classID);
                    if($tmp){
                        @$account['SubTrade']=$tmp['Name'].'|';
                    }
                }
            }
        }

        //是否VIP会员
        $tmp=DB::PGetRows('select * from account_vip where Account=? limit 0,1',array($account['Username']));
        $account['IsVip']='FALSE';
        if($tmp)
        {
            $account['IsVip']='TRUE';
        }
        View::Assign('Account',$account);

        #获取证书数据
        $licences=DB::PGetRows('select * from licence where Account=?',array($account['Username']));
        foreach($licences as $key=>$value)
        {
            $licences[$key]['PicturePath']=Config::PATH_RELATIVE_ATTACHMENT_TEMP.'/'.$licences[$key]['PicturePath'];
        }
        View::Assign('Licences',$licences);

        #获取类别数据
        $categories=DB::PGetRows('select ClassID,count(distinct ClassID) from supply where Account=? group by ClassID',array($account['Username']));

        foreach($categories as $key=>$value)
        {
            //获取类别名称
            $categories[$key]['ClassName']=NULL;
            {
                $tmp=DB::GetRowByID('category','Identifying:'.$categories[$key]['ClassID']);
                if($tmp){
                    $categories[$key]['ClassName']=$tmp['Name'];
                }
            }

            //获取子类数据
            $tmp=DB::PGetRows('select SubclassID,count(distinct SubclassID) from supply where Account=? and ClassID=? group by SubclassID',array
            (
                $account['Username'],
                $categories[$key]['ClassID']
            ));
            $categories[$key]['Subclass']=$tmp;
            foreach($categories[$key]['Subclass'] as &$subclass)
            {
                $subclass['SubclassName']=NULL;
                $tmp=DB::GetRowByID('category','Identifying:'.$subclass['SubclassID']);
                if($tmp){
                    $subclass['SubclassName']=$tmp['Name'];
                }
            }
        }
        View::Assign('Categories',$categories);
        return $account;
    }
}
?>